﻿using System;
using Think9.Models;
using Think9.Services.Base;

namespace Think9.Services.Basic
{
    public class SmsService : BaseService<SmsEntity>
    {
        public int AddSms(string fromid, string toid, string content, int type)
        {
            int icount = 0;
            SmsEntity model = new SmsEntity();
            model.FromId = fromid;
            model.Type = type;
            model.Content = content;
            model.SendTime = DateTime.Now;
            model.BRead = "2";
            model.BDel = "2";

            string[] arr = BaseUtil.GetStrArray(toid, ";");// 以;分割
            for (int i = 0; i < arr.GetLength(0); i++)
            {
                if (arr[i] != null)
                {
                    model.ToId = arr[i].ToString();
                    if (base.Insert(model))
                    {
                        icount++;
                    }
                }
            }

            return icount;
        }
    }
}